﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class News_Menu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            ViewState["crrcat"] = "";//current category ID
            string catid = TTQT.TTQT_Code.TTQTCommon.isNull(Request["catid"],"");
            string newsid = TTQT.TTQT_Code.TTQTCommon.isNull(Request["newsid"], "");
            if(!catid.Equals(""))
            {
                ViewState["crrcat"] = catid;
            }
            else
            {
                if(!newsid.Equals(""))
                {
                    TinTucDAO tin=new TinTucDAO();
                    tin.NewsId = newsid;
                    if(tin.getById())
                    {
                        ViewState["crrcat"] = tin.CategoryId;
                    }
                }
                
            }
            QuanTriDAO qt=new QuanTriDAO();
            rptNewsMenu.DataSource = qt.TinTuc_nhom_getall("-1");
            rptNewsMenu.DataBind();
        }
    }
    public string formatClass(string _catid)
    {
        if(_catid.Equals(ViewState["crrcat"]))
        {
            return "mnu-cat-news";
        }
        return "mnu-cat-news2";
    }
}
